# 读取整个文件
with open('file_read.txt') as file_object:
    contents = file_object.read()
    print(contents)
    print(contents.rstrip())
# 这行代码让Python到文件夹python_work下的文件夹text_files中去查找指定的.txt文件。
# 在Windows系统中，在文件路径中使用反斜杠（\）而不是斜杠（/）
with open('aa/b.txt') as fils:
    contentb = fils.read()
    print(contentb)

filename = 'b.txt'
with open(filename) as file_object:
    lines = file_object.readlines()
for line in lines:
    print(line.rstrip())

# 写入空文件
with open(filename,'w') as file_object:
    file_object.write("i love you")

# 附加到文件
with open(filename,'a') as file_object:
    file_object.write("i love youdddd")
